feat: When resource authorization is set to unauthorized, sub resource cascading is set#4837
Conversation
…e cascading is set
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| } | ||
| emit('submitPermissions', obj) | ||
| } | ||
| const provider_list = ref<Array<Provider>>([]) |
There was a problem hiding this comment.
The provided code generally looks clean and efficient. However, there are a few areas of improvement:
- Return early from
dfsfunction: Inside thedfsfunction, when you find the target node (matchingfolderId), you should immediately return to avoid unnecessary iterations over subsequent nodes.
if (node.id === folderId) {
target = node;
return; // This ensures that no more iterations happen if we found the node.
}With this change, the function will not continue searching further after finding the matching node, which can improve performance.
- Simplifying conditional checks in
submitPermissions:function submitPermissions(value: string, row: any) { const obj = [ ...row.permissions || [], // Merge existing permissions with new ones to handle undefined case. ]; if ('VIEW'.includes(value)) { obj.unshift({ permission: value }); emitSubmitPermissions(...props.data); return; } const { id } = row; // Handle role management cases first ... // Not authorized case specifically for folders if ('NOT_AUTH' == row.resource_type && ['NOT_AUTH'].includes(value)) { getResourcesByFolderId(props.data, id).forEach((n) => { obj.push({ target_id: n.id, permission: 'NOT_AUTH' }); }); } emit('submitPermissions', obj) }
This version simplifies how roles are handled in addition to managing specific resource types (NOT_AUTH) for folders, making the function cleaner and potentially reducing boilerplate logic.
- Consistent naming conventions: Functions like
getResourcesByFolderId, even though written as JavaScript, follow a convention typical in TypeScript or React components. It might be useful to maintain consistency depending on what other languages/technologies you use across your project.
feat: When resource authorization is set to unauthorized, sub resource cascading is set